USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[JumpOfHeight]    Script Date: 05/15/2014 14:38:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[JumpOfHeight]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[JumpOfHeight]
GO

USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[JumpOfHeight]    Script Date: 05/15/2014 14:38:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[JumpOfHeight]
(
	@EXTEND1 varchar(30)
)
RETURNS varchar(30)
AS
BEGIN

DECLARE @return varchar(30),
		@len int,
		@i int

	SET @len = LEN(@EXTEND1)
	SET @i = 1
	SET @return = ''

	WHILE @i <= @len
	BEGIN
		SELECT @return = @return +  MSG.TITLE
		FROM TBL_WEB_USE_ID ID,
			 TBL_WEB_USE_MSG MSG
		WHERE LOWER(TAGNAME) = LOWER('AttemptResult')
			AND ID.TAGID = MSG.TAGID
			AND MSG.XMLCODE = CONVERT(int, SUBSTRING(LTRIM(@EXTEND1), @i, 1))

		SET @i = @i + 1
	END

	RETURN @return

END
GO

